<#include "/template/_ListPageWithTree.html" />
<#assign left_title="模块树"> 
<@left>
<ul id="lefttree" class="easyui-tree" url="${root!}/framemenu/leftTree"></ul>
<script type="text/javascript">
			$(function(){
				$('#lefttree').tree({
					onClick:function(node){
						$('#dg').datagrid({
							url:'${root!}/framemenu/table?code='+node.attributes.menuCode
						});
					}
				});
			});
</script>
</@left> 
<@center>
<div id="tb" style="height:auto">
	<div style="border-bottom: 1px solid #ddd;">
		<a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true"
			onclick="addMenu();">新增模块</a>
			
		<a href="#" class="easyui-linkbutton" onclick="deleteMenu()"
			data-options="plain:true,iconCls:'icon-cancel'">删除选中</a>
			
		&nbsp;&nbsp;#表示未实现功能，@表示只是展开菜单树
	</div>
</div>
<@datatable toolbar="#tb" id="dg" model="${root!}/framemenu/table" fit="true">
	<@columns>
		<@column name="ck" checkbox="true" />
		<@column name="menuName" title="模块名称" formatter="editName" width="200" sortable="true" />
		<@column name="menuUrl" title="模块路径" width="100" />
		<@column name="type" title="类型" width="100" formatter="menuType" />
		<@column name="order" title="排序号" width="100" />
		<@column name="id"  hidden="true" />
	</@columns>
</@datatable>

<script type="text/javascript">

function editName(val,row){
	return '<a href="#" onclick="editMenu(\''+row.id+'\')">'+val+'</a>';
}

function menuType(val,row){
	var name='';
	if(val == 'MENU')
		name = '菜单';
	if(val == 'BTN')
		name = '<span style="color:red;">按钮</span>';
	return name;
}

function addMenu(){
	var node = $('#lefttree').tree('getSelected');
	var parent="";
	if(node){
		parent = node.id;
	}
	OpenDialogRefreshParent("${root!}/framemenu/add?parentId="+parent,"","500","300");
}

function editMenu(id_){
	var id = id_?id_:$('#dg').datagrid("getSelected").id;
	OpenDialogRefresh("${root!}/framemenu/edit/"+id,"","500","500");
}

function deleteMenu(){
	var rows = $('#dg').datagrid("getChecked");
	if(rows.length==0){
		alert("未选择数据");
	}else{
		var ids=StringUtil.array2Str(rows,"id",";");
		$.ajax({
			url:"${root!}/framemenu/delete?ids="+ids,
			type:"GET",
			success:function(msg){
				Alert.info(msg,"系统消息","refresh");
			}
		});
	}
}


</script>
</@center>
